import requests
import json
import re
import sqlite3
import numpy as np
from bs4 import BeautifulSoup

# return a thread json file
def downloadThread(thread):
    if len(thread) <= 19:
        raise ValueError("Invalid URL")

    thread = thread.replace("html", "json")
    thread = str(thread.strip())

    thread_request = requests.get(thread)
    if thread_request.status_code != 200:
        return -1

    thread_json = json.loads(thread_request.text)
    return thread_json
